package ch01;
public class Corn {
    private String name = "玉米";
    private int growTime = 8;
    private int harvestTime = 3;
    private int numsOfFruits = 200;
    private String status = "生长期";
    private boolean isHarvested = false;
    private double harvestCost;

    public Corn() {this(50);
    }

    public Corn(double harvestCost) {
        this.harvestCost = harvestCost;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getGrowTime() {
        return growTime;
    }

    public void setGrowTime(int growTime) {
        this.growTime = growTime;
    }

    public int getHarvestTime() {
        return harvestTime;
    }

    public void setHarvestTime(int harvestTime) {
        this.harvestTime = harvestTime;
    }

    public int getNumsOfFruits() {
        return numsOfFruits;
    }

    public void setNumsOfFruits(int numsOfFruits) {
        this.numsOfFruits = numsOfFruits;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public boolean isHarvested() {
        return isHarvested;
    }

    public void setHarvested(boolean harvested) {
        isHarvested = harvested;
    }

    public double getHarvestCost() {
        return harvestCost;
    }

    public void setHarvestCost(double harvestCost) {
        this.harvestCost = harvestCost;
    }

    /**
     * 输出玉米特性
     */
    public void print(){
        System.out.println("******作物特性******");
        System.out.println("您种植了"+this.name+"。");
        System.out.println("成长期"+this.growTime+"天，"
                +"采摘期"+this.harvestTime+"天，"
                +"产量"+this.numsOfFruits+"，现在处于"+this.status+"。");
        System.out.println(this.name+"属于农作物，收割费用为："+this.harvestCost+"元。");
    }

    /**
     * 生长报告
     * @param day 生长的天数
     */
    public void printGrowReport(int day){
        if (day<this.growTime){
            this.status = "成长期";
            System.out.println("******"+this.name+"生长报告（"+this.status+"）******");
            System.out.println(this.name+"处于"+this.status);
            System.out.println("已生长"+day+"天，距离收获果实还有"+(this.growTime-day)+"天。");
        }else if(day<this.growTime+this.harvestTime){
            this.status = "采摘期";
            System.out.println("******"+this.name+"生长报告（"+this.status+"）******");
            System.out.println(this.name+"处于"+this.status);
            if (!this.isHarvested()){
                System.out.println("果实已成熟，请尽快采摘！");
            }else{
                System.out.println("果实已成熟并已采摘完毕！");
            }
        }else{
            this.status = "已死亡";
            System.out.println("******"+this.name+"生长报告（"+this.status+"）******");
            System.out.println(this.name+this.status+"，请尽快清理土地！");
        }
    }

    /**
     * 采摘
     */
    public void harvest(){
        System.out.println("******"+this.name+"收获果实（"+this.status+"）******");
        if (this.status == "采摘期"){
            if (!this.isHarvested()){
                System.out.println("收获果实"+this.numsOfFruits+"个！");
                System.out.println("使用收割机收割"+this.name+"，费用："+this.harvestCost+"元。");
                this.setHarvested(true);
            }else{
                System.out.println("果实已采摘！");
            }
        }else{
            System.out.println("抱歉！目前没有果实可以采摘！");
        }
    }
}
